package org.com.blbl.hotTopic;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class HotTopicMapper extends Mapper<Object, Text, Text, Text> {

    @Override
    protected void map(Object key, Text value, Context context) throws IOException, InterruptedException {
        //读取一行数据，按 "," 进行切割
        String[] fields = value.toString().split(",");
        if (fields.length > 8) { // 确保有足够的字段
            String partition = fields[7]; // 分区
            String subPartition = fields[8]; // 小分区
            context.write(new Text(partition), new Text(subPartition + ",1")); // 输出分区和小分区及数量1
        }
    }

}
